Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich information on Bootstrap initalization failure #2316

Merged
merged 19 commits into from
Apr 1, 2022

Conversation

DrusTheAxe
Copy link
Member

@DrusTheAxe DrusTheAxe commented Mar 25, 2022

Add new MddBootstrapInitialize2(...options)
If Bootstrap Initialize fails...

...Write to the eventlog
image
image

...Optionally

  • DebugBreak
  • DebugBreak if a debugger is attached to the process
  • FailFast
  • MessageBox (modeled after .NET's) asking if you'd like to install the WindowsAppRuntime and if so, ShellExecute(url) to the download page

image

The optional behavior is triggered by the new MddBootstrapInitialize(...options) parameter or by environment variables

SET MICROSOFT_WINDOWSAPPRUNTIME_BOOTSTRAP_INITIALIZE_DEBUGBREAK=1
SET MICROSOFT_WINDOWSAPPRUNTIME_BOOTSTRAP_INITIALIZE_SHOWUI=1
SET MICROSOFT_WINDOWSAPPRUNTIME_BOOTSTRAP_INITIALIZE_FAILFAST=1

Tested via manual testing (HelloWorldAdvancedCPP.exe) under debugger with memory fiddling and running after setting environment variables.

*.targets updated to provide build-time control (instead of AutoInitialize always unconditionally enabled like in 1.0).

  • To disable the auto-initializer the auto-initialize set the property WindowsAppSDKBootstrapAutoInitialize=false
  • If the auto-initalizer is enabled you can define properties to control the options passed to MddBootstrapInitialize2()
    • WindowsAppSDKBootstrapAutoInitializeOptions_Default=true -- use the default options (OnNoMatch_ShowUI)
    • WindowsAppSDKBootstrapAutoInitializeOptions_None=true -- use no options (None)
    • WindowsAppSDKBootstrapAutoInitializeOptions_*=true -- enable the option where * is one or more of the following
      • OnError_DebugBreak
      • OnError_DebugBreak_IfDebuggerAttached
      • OnError_FailFast
      • OnNoMatch_ShowUI
      • OnPackageIdentity_NoOp

For example, to disable the auto-initializer add to your *proj file:

<PropertyGroup>
    <WindowsAppSDKBootstrapAutoInitialize>false</WindowsAppSDKBootstrapAutoInitialize>
</PropertyGroup>

or to enable the auto-initializer (default) but use the DebugBreak+FailFast options (instead of the default)

<PropertyGroup>
    <WindowsAppSDKBootstrapAutoInitializeOptions_OnError_DebugBreak>true</WindowsAppSDKBootstrapAutoInitializeOptions_OnError_DebugBreak>
    <WindowsAppSDKBootstrapAutoInitializeOptions_OnNoMatch_ShowUI>true</WindowsAppSDKBootstrapAutoInitializeOptions_OnNoMatch_ShowUI>
</PropertyGroup>

https://task.ms/38570577 Improve Bootstrap error discoverability+diagnostics
https://task.ms/38497503 Improve Bootstrap AutoInitialize discoverability+diagnostics
https://task.ms/38570355 MddBootstrapInitializeOptions_OnPackageIdentity_NOOP

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Scottj1s
Copy link
Member

@DrusTheAxe, this is great - thanks for the fit and finish work!

@Scottj1s
Copy link
Member

Per offline discussion, this is helpful but won't accrue to apps already deployed until/unless the store provides support for fwp updates in a future version. Meantime, should developers be alerted to the existence of MddBootstrapInitialize2 at build time (e.g., deprecated attribute on MddBootstrapInitialize)?

@DrusTheAxe
Copy link
Member Author

Per offline discussion, this is helpful but won't accrue to apps already deployed until/unless

Anyone directly calling MddBootstrapInitialize() will need to make a change. Anyone using C# in 1.0 should be using the C# API and will get benefits (I just haven't updated the C# API yet. Note the TODO list :-). Likewise, anyone using 1.1's C++ app will get similar benefits. And the AutoIntializer will be updated to use Init2 and support project properties for non-default control. Things not yet in this PR but coming RSN.

The only 'problem' is existing apps directly calling MddBootstrapInitialize() will need to make a change to their source to get the benefits here.

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

…sAppSDK.BootstrapCommon.targets. Mdd==DynamicDependencies, which is a generic facility for any packcage. Bootstrap==specialization of DynamicDependencies, uniquely for WindowsAppSDK's runtime
@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@Scottj1s Scottj1s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants